﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Admin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (isUserLoggedIn())
        {
            btnOdlogiranje.Visible = true;
            lblKorisnik.Text = "Најавен корисник: "+(string)Session["korisnik"];
            return;

        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
    private bool isUserLoggedIn()
    {
        if (HttpContext.Current.User != null)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return true;
            }
        }
        return false;
    }
    protected void sokri()
    {
        //Klient
        GridView1.Visible = false;
        FormView1.Visible = false;

        //Info
        GridView2.Visible = false;
        FormView2.Visible = false;

        //za maski
        GridView3.Visible = false;
        GridView4.Visible = false;
        GridView5.Visible = false;
        FormView3.Visible = false;
        FormView4.Visible = false;
        FormView5.Visible = false;

        //za zenski
        GridView6.Visible = false;
        FormView6.Visible = false;
        GridView7.Visible = false;
        FormView7.Visible = false;
        GridView8.Visible = false;
        FormView8.Visible = false;


    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        
    }
    protected void btnPrikazi_Click(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedItem.Value == "Облеки за мажи")
        {
            GridView3.Visible = true;
            GridView4.Visible = true;
            GridView5.Visible = true;
            FormView3.Visible = true;
            FormView4.Visible = true;
            FormView5.Visible = true;
             GridView1.Visible = false;
        FormView1.Visible = false;
             GridView2.Visible = false;
        FormView2.Visible = false;
              GridView6.Visible = false;
        FormView6.Visible = false;
        GridView7.Visible = false;
        FormView7.Visible = false;
        GridView8.Visible = false;
        FormView8.Visible = false;
        }
        else if (DropDownList1.SelectedItem.Value == "Облеки за жени")
        {
            GridView6.Visible = true;
            FormView6.Visible = true;
            GridView7.Visible = true;
            FormView7.Visible = true;
            GridView8.Visible = true;
            FormView8.Visible = true;
            GridView3.Visible = false;
        GridView4.Visible = false;
        GridView5.Visible = false;
        FormView3.Visible = false;
        FormView4.Visible = false;
        FormView5.Visible = false;
            GridView2.Visible = false;
        FormView2.Visible = false;
            GridView1.Visible = false;
        FormView1.Visible = false;
        }
        else if (DropDownList1.SelectedItem.Value == "Корисници")
        {
            GridView1.Visible = true;
            FormView1.Visible = true;
              //Info
        GridView2.Visible = false;
        FormView2.Visible = false;

        //za maski
        GridView3.Visible = false;
        GridView4.Visible = false;
        GridView5.Visible = false;
        FormView3.Visible = false;
        FormView4.Visible = false;
        FormView5.Visible = false;

        //za zenski
        GridView6.Visible = false;
        FormView6.Visible = false;
        GridView7.Visible = false;
        FormView7.Visible = false;
        GridView8.Visible = false;
        FormView8.Visible = false;
        }
        else if (DropDownList1.SelectedItem.Value == "Инфо")
        {
            GridView2.Visible = true;
            FormView2.Visible = true;
             GridView1.Visible = false;
        FormView1.Visible = false;
             //za maski
        GridView3.Visible = false;
        GridView4.Visible = false;
        GridView5.Visible = false;
        FormView3.Visible = false;
        FormView4.Visible = false;
        FormView5.Visible = false;

        //za zenski
        GridView6.Visible = false;
        FormView6.Visible = false;
        GridView7.Visible = false;
        FormView7.Visible = false;
        GridView8.Visible = false;
        FormView8.Visible = false;
        }
    }
    protected void btnLogiranje_Click(object sender, EventArgs e)
    {
        Response.Redirect("Login.aspx");
    }

    protected void btnOdlogiranje_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();

        // kolaceto istekuva vcera, t.e. ne e validno
        if (FormsAuthentication.FormsCookieName != null)
        {
            Context.Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddDays(-1);
        }

        // prefrli na default stranata
        Response.Redirect("Doma.aspx");
    }
}